Skip to main content

Managing files or Directories in Linux

 

Command

Description

cp

Copy content from one file to another

Syntax: cp <source> <destination>

 To copy files

# cp file1 file2

 To copy directories

Ex: cp -r dir1 dir2

Note: If file2 & dir2 doesn’t exist it will create

mv

mv stands for move. mv is used to move one or more files or directories from one place to another in a file system like UNIX. It has two distinct functions:

è It renames a file or folder.

è It moves a group of files to a different directory.

find

Find command is used to find the files or directories path. It is exactly like the find option in windows where you can search a file.

Syntax: find / -name filename

grep

Search for a pattern in a file

cd

Switch between directories

tree

Shows directory structure

Ex: tree

 

Comments